import Vue from 'vue'
import Vuex from 'vuex'
import App from './App'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    seller: {},
    goods: [],
    ratings: [],
    position: [], // 添加购物车商品按钮的位置
    isClick: false, // 点击添加商品
    onlyContent: false, // 是否只显示有内容的评论
    selectType: 2 // 评论的类型
  },
  mutations: {
    addToSeller(state, data) {
      state.seller = data
    },
    addToGoods(state, data) {
      state.goods = data
    },
    addToRatings(state, data) {
      state.ratings = data
    },
    getPosition(state, data) {
      state.position = data
      state.isClick = true
    },
    onlycontent(state, data) {
      state.onlyContent = data
    },
    selecttype(state, data) {
      state.selectType = data
    },
    Initialization(state) {
      state.onlyContent = false
      state.selectType = 2
    }
  },
  getters: {
    selectFoods(state) {
      let foods = []
      state.goods.forEach((good) => {
        good.foods.forEach((food) => {
          if (food.count) {
            foods.push(food)
            }
          })
        })
        return foods
      }
  },
  actions: {}
})
